/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/5/20 20:57
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.template.pattern.decorator.impl.more;

import com.example.template.pattern.decorator.base.AbstractBeverage;
import com.example.template.pattern.decorator.base.BeverageDecorator;

/**
 * <p>
 * 容量装饰器
 * </p>
 *
 * @author Yi
 * @version v1.0.0
 * @date 2019-08-10 18:23
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019-08-10
 * @modify reason: {方法名}:{原因}
 * ...
 */
public class Capacity extends BeverageDecorator {

    public Capacity(AbstractBeverage beverage) {
        this.beverage = beverage;
    }

    /**
     * 定义饮料的描述方法【饮料A:+调料1、+调料2、+选择不同的杯容量】
     *
     * @return
     */
    @Override
    public String getDescription() {
        return beverage.getDescription() + "," + getCapacity().getName();
    }

    @Override
    public double cost() {
        double capacityCost = 0;
        switch (getCapacity()) {
            case SMALL:
                capacityCost = 1;
                break;
            case MIDDLE:
                capacityCost = 2;
                break;
            case BIG:
                capacityCost = 3;
                break;
            default:
                break;
        }
        return super.cost() + capacityCost;
    }
}
